package softswitch.job.process;


import javax.ejb.ConcurrentAccessTimeoutException;
import javax.ejb.EJB;
import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
import javax.ejb.Startup;


@Startup
@Singleton
public class ProcessCdrJob {
	
	@EJB
    private ProcessCdrWorker callDetailWorker;
	
	@Lock(LockType.READ)
	@Schedule(second = "*/10", minute = "*", hour = "*", persistent = false)
	public void processCdr() {
		try {
			System.out.println("STARTING CDR REPROCESS");
			callDetailWorker.processCdrs();
			System.out.println("FINISHING CDR REPROCESS");
        }
		catch (InterruptedException e) {
            System.out.println("REPROCESS CDR IS BUSY - InterruptedException");
        }
		catch (ConcurrentAccessTimeoutException e) {
            System.out.println("REPROCESS CDR IS BUSY - ConcurrentAccessTimeoutException");
        }
		
	}

}